package NewTmas.Listeners;

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * Created by IntelliJ IDEA.
 * User: abhatnag
 * Date: 8/18/11
 * Time: 9:04 AM
 * To change this template use File | Settings | File Templates.
 */
public class LogPeriodicRefreshListener implements ItemListener {
    ActionListener refreshtimer;
     Timer timer;
    public LogPeriodicRefreshListener(ActionListener refreshtimer, int i) {
        this.refreshtimer = refreshtimer;
        this.i = i;
    }

    int i;

  public void itemStateChanged(ItemEvent e) {

        if(e.getSource() instanceof JCheckBoxMenuItem){
            JCheckBoxMenuItem item=(JCheckBoxMenuItem )e.getSource();

            if(item .isSelected()) {
                timer=new Timer(i ,refreshtimer);
                timer.start();
            }
            else{
                timer.stop();
            }
        }
    }
}
